package com.bindapp.model;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.bindapp.R;
import com.bindapp.databinding.ActivityShowimgsBinding;
import com.bindapp.widget.roundview.RoundedImageView;

/**
 * Created by apple on 2018/7/20.
 */

public class ShowImgModel extends BaseModel {
    private ActivityShowimgsBinding binding;
    private Integer[] imgs1=new Integer[]{R.drawable.xcimg1,R.drawable.xcimg2,R.drawable.xcimg3};
    private Integer[] imgs2=new Integer[]{R.drawable.alimg1,R.drawable.alimg2,R.drawable.alimg3,R.drawable.alimg4,R.drawable.alimg5};
    public ShowImgModel(Context context,int type){
        super(context);
        binding=DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.activity_showimgs,null,false);
        Integer[] select=null;
        if(type==0){//现场检查
            select=imgs1;
        }else if(type==1){//更多案例
            select=imgs2;
        }
        for(int i:select){
            RoundedImageView view=new RoundedImageView(context);
            view.setOval(false);
            view.setCornerRadius(15);
            view.setScaleType(ImageView.ScaleType.CENTER_CROP);
            RelativeLayout.LayoutParams params=new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            params.setMargins(50,50,50,0);
            view.setLayoutParams(params);
            view.setImageDrawable(ContextCompat.getDrawable(context,i));
            binding.contentview.addView(view);
        }
    }

    @Override
    public ActivityShowimgsBinding getBinding() {
        return binding;
    }
}
